package com.example.test.controller;
import com.example.test.entity.Message;
import com.example.test.service.Messageservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/messages") // 添加请求映射前缀
public class Messagecontroller {
    @Autowired
   public Messageservice messageservice;

    @PostMapping("/send")
    public boolean InsertMessage( String from, String to,String text,Integer id) {
        return messageservice.InsertMessage(from,text,to,id);
    }
    @PostMapping("/jieshou")
    public boolean findByName( String from, String to) {
        return messageservice.findByName(from, to);
    }
    @GetMapping("/{from}/{to}")
    public List<Message> getMessagesBetween(@PathVariable String from, @PathVariable String to) {
        return messageservice.getMessagesBetween(from, to);
    }
     @GetMapping("/getmessage")
    public List<Message> getMessage() {
        return messageservice.getMessage();

    }
    }



